var app = getApp();

Component({
  properties: {
    // 属性值可以在组件使用时指定
    datasource: {
      type: Array,
    },
    orderType: {
      type: String,
    },
    detailUrl: {
      type: String,
    },
    status: {
      type: Number,
    },
  },
  data: {
    language: "",
    regional: "请选择快递公司",
    dateshow_1: false,
    columns: [],
    checkList: [],
    orderPayId: "",
    options: [],
    //确认发货
    dialogVisible: false,
    expressName: "",
    numberName: "",
    addresseeInfo: {},
    showQrcode: false,
    qrcode_url: "",
    // 上拉菜单弹出层
    sendGoogsFail: {
      show: false,
      msg: "",
    },

    showID: "",
    jurisdiction_set: 0,

    showBarter: false,
    showBarter_value: null,
  }, // 私有数据，可用于模板渲染

  lifetimes: {
    // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
    attached() {
      let language = wx.getStorageSync("langIndex");
      this.setData({ language: language.en });
      // this.getTemplate()
      // 在组件实例进入页面节点树时执行
    },
    moved() {},
    detached() {
      // 在组件实例被从页面节点树移除时执行
    },
  },
  pageLifetimes: {
    // 组件所在页面的生命周期函数
    show() {},
    hide() {},
    resize() {},
  },

  methods: {
    toStore(e) {
      let order = e.currentTarget.dataset.order;
      if (order.plugin_id == 92) {
        wx.navigateTo({
          url:
            "/packageA/member/supplier/SupplierShop/SupplierShop?id=" +
            order.id +
            "&fromOrder=1",
        });
      } else if (order.plugin_id == 31 || order.plugin_id == 32) {
        wx.navigateTo({
          url:
            "/packageC/o2o/o2oStore/o2oStore?store_id=" +
            order.id +
            "&fromOrder=1",
        });
      } else if (order.plugin_id == 0) {
        wx.reLaunch({
          url: "/packageG/index/index",
        });
      }
    },
    showMore(e) {
      let order_sn = e.currentTarget.dataset.order.order_sn;
      if (this.data.showID == order_sn) {
        this.setData({
          showID: "",
        });
      } else {
        this.setData({
          showID: order_sn,
        });
      }
    },
    //获取模板id
    getTemplate(order, btn) {
      let urlStr = app.getNetAddresss(
        "member.member.getMiniTemplateCorrespond"
      );
      let that = this;
      app._getNetWork({
        url: urlStr,
        data: {
          small_type: 2,
        },
        success: function (resdata) {
          var res = resdata.data;
          if (res.result == 1) {
            let array = [];
            for (let i = 0; i < res.data.length; i++) {
              array.push(res.data[i].template_id);
            }
            that.setData({
              TemplateArray: array,
            });
            wx.requestSubscribeMessage({
              tmplIds: that.data.TemplateArray,
              success(res) {
                that._toRefund(order, btn);
              },
              fail() {
                that._toRefund(order, btn);
              },
            });
          } else {
            wx.showToast({
              title: res.msg,
              icon: "none",
              duration: 1500,
            });
          }
        },
        fail: function (res) {
          console.log(res);
        },
      });
    },
    multiplePayChange(event) {
      this.setData({
        checkList: event.detail,
      });
      this.triggerEvent("MultiplePayNotification", this.data.checkList);
    },
    //跳转到对应的订单详情
    goOrderdetail(e) {
      let orderType = this.data.orderType;
      // let detailUrl = this.data.detailUrl;
      let orderid = e.currentTarget.dataset.orderid;
      wx.navigateTo({
        url:
          "/packageA/member/orderdetail/orderdetail?order_id=" +
          orderid +
          "&orderType=" +
          orderType,
      });
    },
    //根据按钮值判断用途
    operation(e) {
      let btn = e.currentTarget.dataset.item;
      let order = e.currentTarget.dataset.order;
      let orderidx = e.currentTarget.dataset.orderidx;
      this.setData({
        orderPayId: order.id,
      });
      if (!btn.api && btn.value != 41) {
        if (btn.value == "expediting_delivery") {
          wx.showToast({
            icon: "none",
            title: "已提醒过商家",
            duration: 1000,
          });
        } else {
          //接口没有返回按钮点击请求的地址
          wx.showToast({
            icon: "none",
            title: "error:错误4008820",
            duration: 1000,
          });
        }
        return;
      }

      console.log(btn);
      if (btn.value == 8) {
        //查看物流
        this._checklogistics(order, btn);
      } else if (btn.value == 12) {
        //删除订单
        this._deleteOrder(order, btn, orderidx);
      } else if (btn.value == 10) {
        //评价订单
        this._comment(order, btn);
      } else if (btn.value == 1 || btn.value == "snatch_regiment_pay") {
        //订单支付
        this._toPay(order, btn);
      } else if (btn.value == 13 || btn.value == "snatch_regiment_refund") {
        //退款
        let that = this;
        that.getTemplate(order, btn);
      } else if (btn.value == 9) {
        //取消订单
        this._cancleOrder(order, btn, orderidx);
      } else if (btn.value == 5) {
        //确认订单
        this._confirmOrder(order, btn);
      } else if (btn.value == 18) {
        //退款中
        this._toRefundDetail(order, btn);
      } else if (btn.value == "cashierPay") {
        //订单已付款
        this._cashPayOrder(order, btn);
      } else if (btn.value == "verification_code") {
        this._verification(order, btn);
      } else if (btn.value == 20) {
        this._verificationCash(order, btn);
      } else if (btn.value == 21) {
        //跳到OrderRecord
        wx.navigateTo({
          url:
            "/packageD/member/myOrder/order_record/order_record?order_id=" +
            item.id,
        });
      } else if (btn.value == 22) {
        // 确认支付
        this._payMoney(order, btn);
      } else if (btn.value == 101) {
        wx.navigateTo({
          url:
            "/packageE/pickUpCard/pickUpCardReimburse/pickUpCardReimburse?orderid=" +
            order.id,
        });
      } else if (btn.value == "coupon") {
        console.log(order.id);
        wx.navigateTo({
          url: "/packageD/coupon_share/coupon_share?orderid=" + order.id,
        });
      } else if (btn.value == 23 || btn.value == 60) {
        // 确认发货
        if (order.dispatch_type_id == 3) {
          this.sendGoogs();
        } else {
          this._getCompany();
          this.setData({
            dialogVisible: true,
          });
        }

        this.triggerEvent("stoprefresh", true);
        this.setData({
          expressName: "",
          numberName: "",
        });
      } else if (btn.value == 24 || btn.value == 61) {
        //取消发货
        this._deliverGoodsCancel(order, btn);
      } else if (btn.value == 25) {
        //确认收货
        this._collectGoods(order, btn);
      } else if (btn.value == 26) {
        //关闭订单
        this._closeOrderPay(order, btn);
      } else if (btn.value == 27) {
        this._evaluate(order, btn);
      } else if (btn.value == 28) {
        //卡密
        this._truckList(btn, order);
      } else if (btn.value == 41) {
        //398售后
      } else if (btn.value == 50) {
        //查看发票
        this._checkInvoice(btn, order);
      } else if (btn.value == 11) {
        //酒店确认下单
        this.confirmHotelOrder(btn.api, order.id);
      } else if (
        btn.value == "lease_toy_refund") {
        console.log("申请归还");
        this.getRuruen(btn, order); //进行归还请求
      } else if (btn.value == "lease_toy_apply_adopt") {
        console.log("填写归还");
        wx.navigateTo({
          url: "/packageB/member/OrderReturn/OrderReturn?id=" + order.id,
        });
      } else if (btn.value == "lease_toy_return_info") {
        console.log("归还详情");
        wx.navigateTo({
          url:
            "/packageA/others/order_ruturn_info/order_ruturn_info?id=" +
            order.id,
        });
      } else if (btn.value == "package_deliver") {
        console.log("自提点核销");
        console.log(btn.api);
        this.getQrImg(btn, order);
      } else if (btn.value == "expediting_delivery") {
        this.publicMessage(btn, order, "提醒商家发货");
      } else if (btn.value == "snatch_regiment_barter") {
        // 抢团易货兑换
        this.setData({
          showBarter: true,
          showBarter_value: order.barter,
        });
      } else {
        this.publicMessage(btn, order, btn.name);
      }
    },
    confirmBarter() {
      let urlStr = app.getNetAddresss(
        "plugin.snatch-regiment.api.order.barter"
      );
      urlStr += "&order_id=" + this.data.orderPayId;
      app._getNetWork({
        url: urlStr,
        success: function (resdata) {
          var res = resdata.data;
          if (res.result == 1) {
            wx.showToast({
              title: `易货兑换成功`,
              icon: "success",
              duration: 1500,
              success: function () {},
            });
            that.getdata();
          } else {
            wx.showToast({
              icon: "none",
              title: res.msg,
              duration: 1200,
            });
          }
        },
        fail: function (res) {
          console.log(res);
        },
      });
    },
    cancelBarter() {
      this.setData({
        showBarter: false,
        showBarter_value: null,
      });
    },
    // 自提点确认核销
    getQrImg(btn, order) {
      let urlStr = app.getNetAddresss(btn.api);
      if (btn.value == "package_deliver") {
        urlStr += "&order_id=" + order.id;
      } else {
        urlStr += "&order_pay_id=" + order.id;
      }
      app._getNetWork({
        url: urlStr,
        success: (resdata) => {
          var res = resdata.data;
          if (res.result == 1) {
            this.setData({
              showQrcode: true,
              qrcode_url: res.data.qr_code_url,
            });
          } else {
            wx.showToast({
              icon: "none",
              title: res.msg,
              duration: 1000,
            });
          }
        },
        fail: function (res) {
          console.log(res);
        },
      });
    },

    publicMessage(btn, order, text) {
      let that = this;
      if (!btn.api) {
        return;
      }
      wx.showModal({
        title: "提示",
        content: `确定${text}?`,
        success(res) {
          if (res.confirm) {
            let urlStr = "";
            urlStr += app.getNetAddresss(btn.api);
            urlStr += "&order_id=" + that.data.orderPayId;
            app._getNetWork({
              url: urlStr,
              success: function (resdata) {
                resdata = resdata.data;
                if (resdata.result == 1) {
                  that.triggerEvent("ConfrimOrderNotification", "pay");
                  wx.showToast({
                    icon: "success",
                    title: `${text}成功`,
                    duration: 1000,
                  });
                } else {
                  wx.showToast({
                    icon: "none",
                    title: resdata.msg,
                    duration: 1000,
                  });
                }
              },
              fail: function (resdata) {
                console.log(resdata);
              },
            });
          }
        },
      });
    },
    onClose() {
      this.setData({
        showQrcode: false,
      });
    },
    //查看物流
    _checklogistics(item, btn) {
      //logistics
      console.log(item, btn);
      if (item.is_all_send_goods == 0) {
        wx.navigateTo({
          url:
            "/packageA/member/order/logistics/logistics?id=" +
            item.id +
            "&api=" +
            btn.api,
        });
      } else {
        wx.navigateTo({
          url:
            "/packageE/multiplePackages/multiplePackages?id=" +
            item.id +
            "&api=" +
            btn.api,
        });
      }
    },
    // 申请归还
    getRuruen(btn, order) {
      let urlStr = app.getNetAddresss(btn.api);
      urlStr += "&order_id=" + order.id;
      app._getNetWork({
        url: urlStr,
        success: (resdata) => {
          var res = resdata.data;
          if (res.result == 1) {
            wx.showToast({
              title: res.msg,
              icon: "none",
              duration: 1500,
            });
            this.triggerEvent("ConfrimOrderNotification");
          } else {
            wx.showToast({
              icon: "none",
              title: res.msg,
              duration: 1000,
            });
          }
        },
        fail: function (res) {
          console.log(res);
        },
      });
    },
    //删除订单
    _deleteOrder(item, btn, orderidx) {
      let that = this;
      wx.showModal({
        title: "提示",
        content: "确定删除此订单?",
        success(res) {
          if (res.confirm) {
            //删除当前选中的地址
            let datasource = that.data.datasource;
            datasource.splice(orderidx, 1);
            that.setData({
              datasource: datasource,
            });
            that._sentRequest(btn.api, "&order_id=" + item.id, false);
          }
        },
      });
    },
    _sentRequest(action, params, isIndicator) {
      let urlStr = app.getNetAddresss(action);
      urlStr += params;
      app._getNetWork({
        url: urlStr,
        success: function (resdata) {
          var res = resdata.data;
          if (res.result == 1) {
            wx.showToast({
              title: res.msg,
              icon: "none",
              duration: 1500,
              success: function () {
                setTimeout(function () {
                  //要延时执行的代码
                  wx.navigateBack({
                    delta: 1,
                  });
                }, 1500); //延迟时间
              },
            });
          } else {
            wx.showToast({
              icon: "none",
              title: res.msg,
              duration: 1000,
            });
          }
        },
        fail: function (res) {
          console.log(res);
        },
      });
    },
    //评价订单
    _comment(item, btn) {
      wx.navigateTo({
        url:
          "/packageB/comment/comment?order=" + JSON.stringify(item ? item : {}),
      });
      // 跳到评价订单
      //comment
    },
    _toPay(item, btn) {
      //status-2合并支付 type-1订单支付
      wx.navigateTo({
        url:
          "/packageD/buy/orderPay/orderPay?order_id=" +
          item.id +
          "&status=1" +
          "&api=" +
          btn.api,
      });
    },
    //退款中
    _toRefundDetail(item, btn) {
      //aftersales
      wx.navigateTo({
        url:
          "/packageD/member/myOrder/Aftersales/Aftersales?refund_id=" +
          item.refund_id,
      });
    },
    //退款
    _toRefund(item, btn) {
      //refund
      if (btn.value == "snatch_regiment_refund") {
        //抢团
        wx.navigateTo({
          url:
            "/packageD/member/myOrder/refund/refund?order_id=" +
            item.id +
            "&type=3",
        });
      } else {
        wx.navigateTo({
          url:
            "/packageD/member/myOrder/refund/refund?order_id=" +
            item.id +
            "&type=1",
        });
      }
    },
    //取消订单
    _cancleOrder(item, btn, orderidx) {
      var that = this;
      wx.showModal({
        title: "提示",
        content: "确定取消此订单?",
        success(res) {
          if (res.confirm) {
            //取消当前选中的地址
            let datasource = that.data.datasource;
            datasource.splice(orderidx, 1);
            that.setData({
              datasource: datasource,
            });
            that._sentRequest(btn.api, "&order_id=" + item.id, false);
          }
        },
      });
    },
    //确认收货
    _confirmOrder(item, btn) {
      let that = this;
      let urlStr = app.getNetAddresss(btn.api);
      urlStr += "&order_id=" + item.id;
      wx.showModal({
        title: "提示",
        content: "您确定收到货物?",
        success(resqu) {
          if (resqu.confirm) {
            app._getNetWork({
              url: urlStr,
              success: function (resdata) {
                var res = resdata.data;
                if (res.result == 1) {
                  that.triggerEvent("ConfrimOrderNotification", item.id);
                } else {
                  wx.showToast({
                    icon: "none",
                    title: res.msg,
                    duration: 1000,
                  });
                }
              },
              fail: function (res) {
                console.log(res);
              },
            });
          }
        },
      });
    },
    _cashPayOrder(item, btn) {
      let that = this;
      wx.showModal({
        title: "提示",
        content: "确定此订单已付款?",
        success(res) {
          if (res.confirm) {
            that._sentRequest(
              btn.api,
              "&order_id=" +
                item.id +
                "&order_pay_id=" +
                that.data.order_pay_id,
              false
            );
          }
        },
      });
    },
    _verification(item, btn) {
      //订单核销
      //orderVerification
      wx.navigateTo({
        url:
          "/packageD/member/myOrder/orderVerification/orderVerification?order_id=" +
          item.id +
          "&api=" +
          btn.api,
      });
    },
    _verificationCash(item, btn) {
      let that = this;
      wx.showModal({
        title: "提示",
        content: "确定此订单已付款?",
        success(res) {
          if (res.confirm) {
            that._sentRequest(
              btn.api,
              "&order_id=" +
                item.id +
                "&order_pay_id=" +
                that.data.order_pay_id,
              false
            );
          }
        },
      });
    },
    //确认支付
    _payMoney(item, btn) {
      let that = this;
      wx.showModal({
        title: "提示",
        content: "确认支付该订单?",
        success(res) {
          if (res.confirm) {
            let urlStr = "";
            if (
              that.data.orderType == "supplier" ||
              that.data.orderType == "subsidiary"
            ) {
              urlStr += app.getNetAddresss(btn.api);
              urlStr += "&order_id=" + that.data.orderPayId;
            } else {
              urlStr += app.getNetAddresss(
                "plugin.store-cashier.frontend.store.center.order-operation.pay"
              );
              urlStr += "&order_id=" + that.data.orderPayId;
            }
            app._getNetWork({
              url: urlStr,
              success: function (resdata) {
                var res = resdata.data;
                if (res.result == 1) {
                  that.triggerEvent("ConfrimOrderNotification", "pay");
                  wx.showToast({
                    icon: "success",
                    title: "支付成功",
                    duration: 1000,
                  });
                } else {
                  wx.showToast({
                    icon: "none",
                    title: res.msg,
                    duration: 1000,
                  });
                }
              },
              fail: function (res) {
                console.log(res);
              },
            });
          }
        },
      });
    },
    //获取快递公司
    _getCompany() {
      let that = this;
      let urlStr = "";
      if (that.data.orderType == "supplier") {
        urlStr += app.getNetAddresss(
          "plugin.supplier.frontend.order.express-company"
        );
      } else if (that.data.orderType == "subsidiary") {
        urlStr += app.getNetAddresss(
          "plugin.subsidiary.frontend.order.express-company"
        );
      } else {
        urlStr += app.getNetAddresss(
          "plugin.store-cashier.frontend.store.center.sendOrder"
        );
      }
      urlStr += "&order_id=" + that.data.orderPayId;
      app._getNetWork({
        url: urlStr,
        success: function (resdata) {
          var res = resdata.data;
          if (res.result == 1) {
            that.setData({
              options: res.data.express_companies,
            });
            var arrayOfSquares = that.data.options.map(function (item) {
              return item.name;
            });
            if (!app._isTextEmpty(res.data.jurisdiction_set)) {
              that.setData({
                jurisdiction_set: res.data.jurisdiction_set,
              });
            }
            that.setData({
              columns: arrayOfSquares,
              addresseeInfo: res.data.address,
            });
          }
        },
        fail: function (res) {
          console.log(res);
        },
      });
    },
    //取消发货
    _deliverGoodsCancel(order, btn) {
      let that = this;
      wx.showModal({
        title: "提示",
        content: "确定取消发货?",
        success(res) {
          if (res.confirm) {
            let urlStr = "";
            if (
              that.data.orderType == "supplier" ||
              that.data.orderType == "subsidiary"
            ) {
              urlStr += app.getNetAddresss(btn.api);
              urlStr += "&order_id=" + that.data.orderPayId;
            } else if (that.data.orderType == "auction") {
              urlStr += app.getNetAddresss(
                "plugin.auction.api.order-operation.cancel-send"
              );
              urlStr += "&order_id=" + that.data.orderPayId;
            } else {
              urlStr += app.getNetAddresss(
                "plugin.store-cashier.frontend.store.center.order-operation.cancel-send"
              );
              urlStr += "&order_id=" + that.data.orderPayId;
            }
            app._getNetWork({
              url: urlStr,
              success: function (resdata) {
                var res = resdata.data;
                if (res.result == 1) {
                  that.triggerEvent("ConfrimOrderNotification", "pay");
                  wx.showToast({
                    icon: "success",
                    title: "取消发货成功",
                    duration: 1000,
                  });
                } else {
                  wx.showToast({
                    icon: "none",
                    title: res.msg,
                    duration: 1000,
                  });
                }
              },
              fail: function (res) {
                console.log(res);
              },
            });
          }
        },
      });
    },
    //确认收货
    _collectGoods(order, btn) {
      let that = this;
      wx.showModal({
        title: "提示",
        content: "确认收货?",
        success(res) {
          if (res.confirm) {
            let urlStr = "";
            if (
              that.data.orderType == "supplier" ||
              that.data.orderType == "subsidiary" ||
              that.data.orderType == "pickup_card"
            ) {
              urlStr += app.getNetAddresss(btn.api);
              urlStr += "&order_id=" + that.data.orderPayId;
            } else {
              urlStr += app.getNetAddresss(
                "plugin.store-cashier.frontend.store.center.order-operation.receive"
              );
              urlStr += "&order_id=" + that.data.orderPayId;
            }
            app._getNetWork({
              url: urlStr,
              success: function (resdata) {
                var res = resdata.data;
                if (res.result == 1) {
                  that.triggerEvent("ConfrimOrderNotification", "pay");
                  wx.showToast({
                    icon: "success",
                    title: "收货成功",
                    duration: 1000,
                  });
                } else {
                  wx.showToast({
                    icon: "none",
                    title: res.msg,
                    duration: 1000,
                  });
                }
              },
              fail: function (res) {
                console.log(res);
              },
            });
          }
        },
      });
    },
    //关闭订单
    _closeOrderPay(order, btn) {
      let that = this;
      wx.showModal({
        title: "提示",
        content: "确定关闭订单?",
        success(res) {
          if (res.confirm) {
            let urlStr = "";
            if (
              that.data.orderType == "supplier" ||
              that.data.orderType == "subsidiary"
            ) {
              urlStr += app.getNetAddresss(btn.api);
              urlStr += "&order_id=" + that.data.orderPayId;
            } else {
              urlStr += app.getNetAddresss(
                "plugin.store-cashier.frontend.store.center.order-operation.close"
              );
              urlStr += "&order_id=" + that.data.orderPayId;
              urlStr += "&shop_id=" + null;
            }
            app._getNetWork({
              url: urlStr,
              success: function (resdata) {
                resdata = resdata.data;
                if (resdata.result == 1) {
                  that.triggerEvent("ConfrimOrderNotification", "pay");
                  wx.showToast({
                    icon: "success",
                    title: "关闭订单成功",
                    duration: 1000,
                  });
                } else {
                  wx.showToast({
                    icon: "none",
                    title: resdata.msg,
                    duration: 1000,
                  });
                }
              },
              fail: function (resdata) {
                console.log(resdata);
              },
            });
          }
        },
      });
    },
    // 评价
    _evaluate(order, btn) {
      //抢单评价
      //DeliveryEvaluate
      wx.navigateTo({
        url:
          "/packageD/member/myOrder/DeliveryEvaluate/DeliveryEvaluate?order_id=" +
          order.order_id +
          "&api=" +
          btn.api +
          "&name=distributor",
      });
    },
    //卡密
    _truckList(btn, order) {
      //TruckList
      wx.navigateTo({
        url:
          "/packageD/member/myOrder/truckList/truckList?order_id=" + order.id,
      });
    },
    //查看发票
    _checkInvoice(btn, order) {
      //Invoice
      wx.navigateTo({
        url: "/packageD/member/myOrder/invoice/invoice?order_id=" + order.id,
      });
    },
    //快递单号输入值绑定
    numberNamebtn(e) {
      let val = e.detail.value;
      this.setData({
        numberName: val,
      });
    },
    //确认发货
    sendGoogs(event) {
      if (!event || event.detail === "confirm") {
        let that = this;
        // 发货失败上拉弹出菜单函数
        const sendGoogsFail = (msg) => {
          this.setData({
            sendGoogsFail: {
              show: true,
              msg,
            },
            dialogVisible: false,
          });
        };
        if (this.data.orderType == "supplier") {
          let urlStr = "";
          urlStr += app.getNetAddresss("plugin.supplier.frontend.order.send");
          let json = {
            order_id: that.data.orderPayId,
            express_code: that.data.expressName.value,
            express_company_name: that.data.expressName.name,
            express_sn: that.data.numberName,
          };
          app._postNetWork({
            url: urlStr,
            showToastIn: false,
            data: json,
            success: function (resdata) {
              var res = resdata.data;
              console.log("msg=", res);
              if (res.result == 1) {
                that.setData({
                  dialogVisible: false,
                });
                that.triggerEvent("stoprefresh", false);
                that.triggerEvent("ConfrimOrderNotification", "pay");
                wx.showToast({
                  icon: "success",
                  title: "发货成功",
                  duration: 1000,
                });
              } else {
                sendGoogsFail(res.msg);
              }
            },
            fail: function (res) {},
          });
        } else if (this.data.orderType == "subsidiary") {
          let urlStr = "";
          urlStr += app.getNetAddresss("plugin.subsidiary.frontend.order.send");
          let json = {
            order_id: that.data.orderPayId,
            express_code: that.data.expressName.value,
            express_company_name: that.data.expressName.name,
            express_sn: that.data.numberName,
          };
          app._postNetWork({
            url: urlStr,
            showToastIn: false,
            data: json,
            success: function (resdata) {
              var res = resdata.data;
              if (res.result == 1) {
                that.setData({
                  dialogVisible: false,
                });
                that.triggerEvent("stoprefresh", false);
                that.triggerEvent("ConfrimOrderNotification", "pay");
                wx.showToast({
                  icon: "success",
                  title: "发货成功",
                  duration: 1000,
                });
              } else {
                sendGoogsFail(res.msg);
              }
            },
            fail: function (res) {},
          });
        } else if (this.data.orderType == "auction") {
          let urlStr = "";
          urlStr += app.getNetAddresss(
            "plugin.auction.api.order-operation.send"
          );
          let json = {
            order_id: that.data.orderPayId,
            express_code: that.data.expressName.value,
            express_company_name: that.data.expressName.name,
            express_sn: that.data.numberName,
          };
          app._postNetWork({
            url: urlStr,
            showToastIn: false,
            data: json,
            success: function (resdata) {
              var res = resdata.data;
              if (res.result == 1) {
                that.setData({
                  dialogVisible: false,
                });
                that.triggerEvent("stoprefresh", false);
                that.triggerEvent("ConfrimOrderNotification", "pay");
                wx.showToast({
                  icon: "success",
                  title: "发货成功",
                  duration: 1000,
                });
              } else {
                sendGoogsFail(res.msg);
              }
            },
            fail: function (res) {},
          });
        } else {
          let urlStr = "";
          urlStr += app.getNetAddresss(
            "plugin.store-cashier.frontend.store.center.order-operation.send"
          );
          urlStr += "&order_id=" + that.data.orderPayId;
          urlStr += "&express_code=" + that.data.expressName.value;
          urlStr += "&express_company_name=" + that.data.expressName.name;
          urlStr += "&express_sn=" + that.data.numberName;
          app._getNetWork({
            url: urlStr,
            success: function (resdata) {
              var res = resdata.data;
              if (res.result == 1) {
                console.log("result=", res.result);
                that.triggerEvent("ConfrimOrderNotification", "pay");
                wx.showToast({
                  icon: "success",
                  title: "发货成功",
                  duration: 1000,
                });
                that.setData({
                  dialogVisible: false,
                });
              } else {
                sendGoogsFail(res.msg);
              }
            },
            fail: function (res) {},
          });
        }
      } else {
        this.setData({
          dialogVisible: false,
        });
        this.triggerEvent("stoprefresh", false);
      }
    },
    // 关闭上拉弹出
    colseSendGoogsFailPopup() {
      this.setData({
        "sendGoogsFail.show": false,
      });
    },
    //快递选择
    seleRegional: function () {
      this.setData({
        dateshow_1: true,
      });
    },
    onCancelbtn: function () {
      this.setData({
        dateshow_1: false,
      });
    },
    onConfirmbtn: function (e) {
      let index = e.detail.index;
      let val = e.detail.value;
      let array = this.data.options;
      this.setData({
        dateshow_1: false,
        regional: val,
        expressName: array[index],
      });
    },
    // for prevent touchmove
    noop: function noop() {},
    //value 11 酒店确认下单
    confirmHotelOrder(api, id) {
      let urlStr = "";
      urlStr += app.getNetAddresss(api);
      urlStr += "&order_id=" + id;
      app._getNetWork({
        url: urlStr,
        success: function (resdata) {
          var res = resdata.data;
          if (res.result == 1) {
            wx.showToast({
              icon: "none",
              title: res.msg,
              duration: 1000,
            });
          } else {
            wx.showToast({
              icon: "none",
              title: res.msg,
              duration: 1000,
            });
          }
        },
        fail: function (res) {
          console.log(res);
        },
      });
    },
    copyorderbtn(e) {
      let copydata = e.currentTarget.dataset.copydata;
      wx.setClipboardData({
        data: copydata ? copydata : "",
        success(res) {
          wx.showToast({
            icon: "none",
            title: "复制成功",
            duration: 1000,
          });
        },
      });
    },
  },
});
